<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<title>文章评论列表-文章管理-{$site.BACK_NAME}</title>
<include file="Public:jscss" />
</head>
<body>
<div class="wrap">
 <include file="Public:head"/>
 <div class="mainBody">
  <include file="Public:left"/>
  <div id="Right">
   <div class="Item hr">
    <div class="current">文章评论列表</div>
   </div>
   <div class="Item">
	主题：{$news.title}<br/><br/>
	<foreach name="praise" item="vo">
	[ <a link="{$vo['uid']}" href="javascript:void(0)" name="{$vo.a_raname}" data-tid="{$vo.uid}" class="cfz_reply">{$vo.a_raname}</a> ] 
	</foreach>
	<notempty name="praise">觉得很赞</notempty>
   </div>
   <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
	<thead>
	 <tr>
	  <td width="5%">序号</td>
	  <td width="10%">操作人</td>
	  <td width="55%">回复内容</td>
	  <td width="10%">回复时间</td>
	  <td width="20%">操作</td>
	 </tr>
	</thead>
	<volist name="comment" id="vo">
	<tr align="center" id="tr_{$vo.id}">
	 <td>{$i}</td>
	 <td align="left"><a href="javascript:void(0)" name="{$vo.a_raname}" data-tid="{$vo.aid}" class="cfz_reply"><present name="vo.a_raname">{$vo['a_raname']}<else/>{$vo['a_nkname']} </present></a></td>
	 <td align="left">
	  <notempty name="vo.tid"><b>&nbsp;回复&nbsp;[<a href="javascript:void(0)" name="{$vo.t_raname}" data-tid="{$vo.tid}" class="cfz_reply">{$vo['t_raname']}</a>]&nbsp;:</b></notempty>
	  {$vo['content']}
	 </td>
	 <td>{$vo.add_time|date="Y-m-d H:i:s",###}</td>
	 <td>
	  <if condition="$news['re_score'] gt 0">
	  [ <a href="javascript:void(0)" class="cfz_bestans" data-win="{$vo.is_win}"><if condition="$vo['is_win'] neq 1"><font color='green'>答案</font><else/><font color='red'>否决</font></if> </a> ]
	  </if>
	  [ <a href="javascript:void(0)" name="{$vo.a_raname}" data-tid="{$vo['aid']}" class="cfz_reply">回复 </a> ]
	  [ <a href="javascript:void(0)" data-id="{$vo['id']}" class="cfz_del">删除 </a> ]
	 </td>
	</tr>
	</volist>
   </table>
   <div class="commonBtnArea" >
	<form action="" method="post" id="quickForm">
	 快捷回复:
	 <input type="hidden" name="nid" value="{$news.id}"/>
	 <input type="hidden" name="aid" value="{$admin_id}"/>
	 <input type="hidden" name="tid" id="quickTid" value="0" />
	 <textarea name="content" id="quickContent" rows="1" style="width:800px;" placeholder="请输入回复内容"></textarea>
	 <button class="btn cfz_submit">确定</button>
	 <button class="btn hidden cfz_cancel">取消回复对象</button>
    </form>
   </div>
  </div>
 </div>
</div>
<div class="clear"></div>
<include file="Public:foot"/>
</body>
<script type="text/javascript">
$(function(){
	//回复文章
	$(".cfz_submit").click(function(){
		if($("#quickContent").val().length == 0){
			$.jBox.tip('回复内容不能为空', 'info');
			return false;
		}
		commonAjaxSubmit("{:U('News/reply')}", "#quickForm");
	});
	//选中回复
	$(".cfz_reply").click(function(){
		var t_id = $(this).data("tid");
		$("#quickTid").val(t_id);
		var a_name = $(this).attr("name");
		$("#quickContent").attr("placeholder", "回复"+a_name+":");
		$("#quickContent").focus();
		$(".cfz_cancel").removeClass('hidden');
	});
	//取消选中
	$(".cfz_cancel").click(function(){
		$("#quickTid").val(0);
		$("#quickContent").attr("placeholder", "请输入回复内容");
		$("#quickContent").focus();
		$(".cfz_cancel").addClass('hidden');
		return false;
	});
	//答案选择
	$(".cfz_bestans").click(function(){
		var url = "{:U('News/bestans')}";
		var obj=$(this);
		var id=$(this).parents("tr").attr("id");
		id = id.replace("tr_","");
		var iswin = $(this).data("win");
		$.getJSON(url, { id:id, is_win:iswin }, function(json){
			if(json.errcode==0){
				$.jBox.success(json.data.txt, '操作成功');
				$(obj).data("win",json.data.is_win).html(iswin==1?"<font color='green'>答案</font>":"<font color='red'>否决</font>");
			}else{
				$.jBox.tip(json.errmsg, 'error');
			}
		});
	});
	//单个删除
	$(".cfz_del").click(function(){
		var c_id = $(this).data("id");
		$.jBox.confirm(
			'您真的打算删除本条评论吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					$.getJSON("{:U('News/cdel')}", {id:c_id}, function(json){
						if(json.errcode==0){
							$("#tr_"+c_id).remove();
							$.jBox.tip(json.errmsg, 'success');
						}else{
							$.jBox.tip(json.errmsg, 'error');
						}
					});
					$.jBox.tip("系统处理中，请稍候....", 'loading');
					return true;
				}
			}
		);	
	});
});
</script>
</html>